# -*- coding: utf-8 -*-

'''eof
name:批量评分
code:CR_Score
tableName:
columnName:
groups:批量评分
dependencies:BATCH_SCORE_MONTH
type:常用指标
datasourceType:在线指标
description:
eof'''


import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')


# BATCH_SCORE_MONTH = [{"score":123}]


def format_data(base_name):
    try:
        return base_name if isinstance(base_name, list) and len(base_name) > 0 else [{}]
    except:
        return [{}]


def float_check(num):
    try:
        float(num)
        return True
    except:
        return False


def CR_Score():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/', ' ']
    try:
        score_list = format_data(BATCH_SCORE_MONTH)

        if score_list == [{}]:
            return u'缺失值'
        else:
            if len(score_list) >= 1:
                score = score_list[0].get("score")
                return float(score) if float_check(score) else u'缺失值'
            else:
                return u'缺失值'
    except:
        return u'缺失值'


result = CR_Score()